#ifndef __GLF_CORE_MUTEX_H_INCLUDED__
#define __GLF_CORE_MUTEX_H_INCLUDED__

#include <glf/config.h>
#include <glf/core/lockGuard.h>

namespace glf {

enum MutexType
{
	MUTEX_NORMAL,
	MUTEX_RECURSIVE
};

struct Mutex : private NonCopyable {
	Mutex(MutexType type = MUTEX_NORMAL);
	~Mutex(); //virtual ?

	void Lock();
	bool TryLock(); //try lock might not be supported on all platforms
	void Unlock();

	GLF_DECLARE_IMPL(44)
};

typedef LockGuard<Mutex>    LockScope;
typedef UnlockGuard<Mutex>  UnlockScope;
typedef TryLockGuard<Mutex> TryLockScope;

#if GLF_ENABLE_DEBUGGER
struct DebuggerMutex : private NonCopyable {
	DebuggerMutex(MutexType type = MUTEX_NORMAL);
	~DebuggerMutex();

	void Lock();
	bool TryLock(); //try lock might not be supported on all platforms
	void Unlock();

	char mImplBuffer[50];
	Mutex::Impl& m;
};
#endif

} //namespace glf

#endif
